package com.example.admin.yuejian_22.Fragment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.example.admin.yuejian_22.Adapter.ClubDetail_BFragmentAdapter;
import com.example.admin.yuejian_22.Bean.ClubList;
import com.example.admin.yuejian_22.Listener.UserListener;
import com.example.admin.yuejian_22.Model.UserModel;
import com.example.admin.yuejian_22.R;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by Admin on 2017/10/22.
 */

public class ClubDetail_BFragment extends Fragment {
    //    private View view = null;
    public RecyclerView recyclerView;
    private Context Context;
    private String Club_id;
    private ClubList info;
    private List<ClubList.ClubcourseEntity> Data;
    private UserListener userListener = new UserListener() {
        @Override
        public void onResponse(Object beanobject) {
            info = (ClubList) beanobject;
            Data =info.getClubcourse();
            recyclerView.setAdapter(new ClubDetail_BFragmentAdapter(getActivity(), Data));
        }

        @Override
        public void onFail(String msg) {
            Toast.makeText(getActivity(), ""+msg, Toast.LENGTH_SHORT).show();Toast.makeText(getActivity(), ""+msg, Toast.LENGTH_SHORT).show();
        }

    };


    public void initRecyclerView(View view) {
        recyclerView = (RecyclerView) view.findViewById(R.id.lv_club_course);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.listview_club, container, false);
        initRecyclerView(view);
        Intent intent = getActivity().getIntent();
        Club_id = intent.getStringExtra("Clubid");


        UserModel userModel = new UserModel();
        userModel.getCourseinfo(Club_id, userListener);
        return view;
    }

}


